/**
 * @author Linrui
 * @since 2011-06-10
 */
package com.qeado.colleage.dao.ibatis;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.qeado.base.BaseDao;
import com.qeado.colleage.dao.ColleageDao;
import com.qeado.colleage.model.Colleage;
import com.qeado.user.model.User;
import com.qeado.util.PageHelper;
import com.qeado.util.ParameterMap;

@Repository
@SuppressWarnings("unchecked")
public class ColleageDaoImplement extends BaseDao implements ColleageDao {

	public PageHelper listAll(int pageNum, int pageSize, String typeCode,
			String orderBy, String asc) {
		PageHelper pageHelper = new PageHelper();
		pageHelper.setPageSize(pageSize);
		int startRecored = (pageNum - 1) * pageSize;
		ParameterMap parameterMaps = new ParameterMap();
		parameterMaps.setPageSize(pageSize);
		parameterMaps.setStartRecored(startRecored);
		if( "all".equals(typeCode) || typeCode == null || "".equals(typeCode)) {
			parameterMaps.setParameter1(orderBy);
			parameterMaps.setParameter2(asc);
			pageHelper.setObjList((List) this.getSqlMapClientTemplate()
					.queryForList("Colleage.listAll", parameterMaps));
			pageHelper.setRecordCount((Integer) this.getSqlMapClientTemplate()
					.queryForObject("Colleage.getCount"));
		} else {
			parameterMaps.setParameter1(typeCode);
			parameterMaps.setParameter2(orderBy);
			parameterMaps.setParameter3(asc);
			pageHelper.setObjList((List) this.getSqlMapClientTemplate()
					.queryForList("Colleage.listAllByType", parameterMaps));
			pageHelper.setRecordCount((Integer) this.getSqlMapClientTemplate()
					.queryForObject("Colleage.getCountByType", typeCode));
		}
		pageHelper.setCurrentPage(pageNum);
		pageHelper.setPageCount();
		return pageHelper;		
	}

	public PageHelper listByKey(int pageNum, int pageSize, String type,
			String orderBy, String asc, String key , String level) {
		// TODO Auto-generated method stub
		return null;
	}

	public Colleage queryById(String id) {
		// TODO Auto-generated method stub
		return null;
	}

	public String insertColleage(Colleage colleage, User user) {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean updateColleage(Colleage colleage) {
		// TODO Auto-generated method stub
		return false;
	}

	public boolean deleteColleage(String id) {
		// TODO Auto-generated method stub
		return false;
	}

}
